/** * 根据组件名获取父级 *
 * @param vm
 * @param name
 * @returns {Vue | null}
 */
export function getVmParentByName(vm: any, name: string): any | null {
  const parent = vm.$parent
  if (parent && parent.$options) {
    if (parent.$options.name === name) {
      return parent
    } else {
      const res = getVmParentByName(parent, name)
      if (res) {
        return res
      }
    }
  }
  return null
}
